package com.itheima.sh.controller;

import com.itheima.sh.feign.FeignApi;
import com.itheima.sh.pojos.User;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @author balisong_fcs
 * @date 2020/12/20 19:14
 */
@RestController
@RequestMapping("feign")
public class FeignController {

    @Autowired
    private FeignApi feignApi;

    @GetMapping("{id}")
   // @HystrixCommand(fallbackMethod = "queryByIdFallBack")
    public User queryById(@PathVariable("id") String id) {
        return feignApi.queryById(id);
    }

    /**
     *@desc 降级方法
     *@params
     *@return
     */
   /* public User queryByIdFallBack(String id) {
        User user = new User();
        user.setName("暂停服务");
        return user;
    }*/
}
